package com.jackrain.nea.fc.cp.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 店仓查询
 * Mapper
 *
 * @author xuxinshuai
 * @create 2018/05/05
 */
@Mapper
public interface WmsCStoreMapper {



    /**
     * @return List
     */
    @Select("select \n" +
            "a.ECODE as ecode,\n" +
            "a.ENAME as ename,\n" +
            "case when a.storenature = 'STO' then 'CO' else 'WH' end as store_nature,\n" +
            "a.ALLNAME AS all_name,\n" +
            "a.ADDRESS as address,\n" +
            "b.ENAME as cp_c_pro,\n" +
            "c.ENAME as cp_c_city,\n" +
            "d.ENAME as cp_c_dist,\n" +
            "a.CONTACTER as linkman,\n" +
            "a.MOBIL as phone,\n" +
            "a.POST as post,\n" +
            "a.EMAIL as email,\n" +
//                            " NULL /a.WMSCODE/ as WMS_STORE_CODE,\n" +
//                            " NULL /a.WMSNAME/ as WMS_STORE_NAME,\n" +
//            "a.ISWMS as iswms,\n" +
            "a.WMS_STORE_ECODE as wms_store_code,\n" +
            "a.WMS_STORE_ENAME as wms_store_name,\n" +
            "a.FAX as fax,\n" +
            "e.ECODE as region_code,\n" +
            "e.ENAME as region_name,\n" +
            "a.LOGISTICS as logistics_batch,\n" +
            "f.ENAME as transport_company,\n" +
            "a.PREINDAYS as passage_days,\n" +
            "a.REMARK as remark,\n" +
            "80 as recive_status,\n" +
            "NOW() as write_time,\n" +
            "NULL AS recive_time,\n" +
            "NULL AS recive_err_msg,\n" +
            "a.OWNERENAME as owner_ename,\n" +
            "a.OWNERNAME as owner_name,\n" +
            "a.MODIFIERENAME as modifier_ename,\n" +
            "a.MODIFIERNAME as modifier_name,\n" +
            "a.MODIFIEDDATE as modified_date\n" +
            "from cp_c_store a\n" +
            "left join CP_C_REGION b on b.REGIONTYPE='PROV' and a.CP_C_PRO_ID = b.ID\n" +
            "left join CP_C_REGION c on c.REGIONTYPE='CITY' and a.CP_C_CITY_ID = c.ID\n" +
            "left join CP_C_REGION d on d.REGIONTYPE='DIST' and a.CP_C_DIST_ID = d.ID\n" +
            "left join cp_c_storeorg e on e.ISDISTRIB='1' and a.CP_C_DISTRIB_ID = e.ID\n" +
            "left join CP_C_EXPCOMPANY f on a.CP_C_EXPCOMPANY_ID = f.ID WHERE a.ID IN ( #{ids} )" )
            List<HashMap> selectwmsStoresql(String ids);



}
